import * as PIXI from "../../../../../../libs/pixi.4.8.0";
import {gContext} from "./Main";

export default class SystemLoadingVc extends PIXI.Container {

    constructor() {
        super();
        this.progressBase64Img = '' +
            'BMVEUAAAD////////////////////////////////////////////////////////////////////////////////////' +
            '/////////////////////////////////////////////////////////////////////////////////////////////' +
            '///////////////////AJcWoAAAAMnRSTlMAGcwE3CuZv8YyJWsS0Ha5kX6Fo02zPQk41yHUrR6pi0ALUnFhR2SfWlZeR' +
            'A5ZSWYWbjfWPXsAAAfoSURBVHjazdwLc5pAEMDxJdfDAleCghxFieArYjQx3//Lde9YqrZqHjzOv81Mp9Npf7MLPhIUmm' +
            'bx6O3NpsKq2ft7khRgLL70g58Pql+qyWTyG/tRNw5nSw49VySePfiJoYpkp7S/uondJ83K7cEAWVUkO5kasaiEQS8Vkf0' +
            '4wK7QJkQ74iauJbq3cX/8+IgwSrOOskk9tDPazMJ2XdqKKECW7ihTOKJdOQumlk5I6KjcHo8Rhr8GRPtZD+3kLDjfJ8Go' +
            'TmhlOB2r0KS3ebrPwc1DbYSkzmg8mE41jIZ2vk/s+j4fHEJ1sNAiep7qxtP/aU+2523jk/KNPwzDmvawtM5q8xTloyeMa' +
            'CTTBf6cF+zCf8RYIUTiPU4mg5X1XztoJVmGT1WVjGj2IjkwuBnqjprW95mOQqyWkc3eZ59cCNshpIuhRc+h7ik80jxOqi' +
            'Y2Bk0q/Ofno0wXzi9t8Bs7lU3WGNg2yoimZMHqm/+eFC2uM7d1R1kQN1gAI1rzO45Sq/BGNPtVANYm7Tsy+WarCIf5GTS' +
            'uaC6TfhDYAbmwWTvP95hoeAqIRYDZf2kLAS0lG8nke1BFsm0Bui6Gxr7i8mYz7aKxJdBqu2/JyIWy2jYU0HLyezK5HM1U' +
            'BFsX0HrsW7JohP2lzRlg3co+t5Jcsf7Scugo8VUZH45URIuhs8TXHjeFP0QZ0c7n1ams+PCBaKgaVeUMOox95QSIhtQll' +
            '0EZx0X6teylA9cNmbj5COkji9oz6Dz2yUfN0ldVM/Mk9JD81DITxSLZ4gC9tPvEMgvP9xc1zYWeEh8vM1osFrUsgd76cJ' +
            'mWt8CqoW0Z9Bb7aJmlp2XKtRDQY8XtkXEPI5oDvSZujUzukUW0DYNeY7eOf+4dE9Bzu+sjk+Xa894qVwy9d31k6XK9Jtp' +
            'SQu/JqyOLEKZomAMGEldOTGu7XC4r2Z6BgdiVkSUKVg2Ng4GujUyW2y3RNhKMJC8+/0/3Gy3DHDCUuLTLfINp2laCoeSF' +
            'XRbzzV7JsByMZWX/7TIty82+oh3AWDuEkQ2oeF4iTckiBsZiWZaRjBQymqNM0zgYzMqw011aCCOaAIPt0pSGRgyOsIpmb' +
            'JO0y7Si1buMo4hoDhjNSjG9zwKwYoWuipaB0YTrEk0AJl4jbI6ySILRpIsyTbMASxFW0XIGRmOpW9OUhL++Es0Bw2WuS7' +
            'QCAOLVimQZGE7wWiYAJMKIJsBwO04y9wBQ5C+rivYiwXDS5UTLGIj85eVFy2IGhmMIq2gpAyuvZcaPfQCEEU0qmKbdFYy' +
            '7BaRxTrQUjGc5DskEwuK4khm/twA4OBjB3Jhk+R3ALKeWWcCThGgFGK9wHKJlCEOZ6p5gjuMqGNHuApYcYY5yJcl9wBKE' +
            'JTXMqWh3AkNaBXMdLcPuBaZpXMHUb+4EFsdaRrCKdiewOFG3RMOIdiewamgcMu5Qxp8nAog8JxoHi3OiWWC8LMe0LAXBV' +
            'fcCe8mJpmEku4MHcfflRdMUrOCU44LxnBXJcku9/CXZXcBWRENYWstc8y9GYoRpWiyAZa5LNPMv3/BFZCXLC4CD6xJtB4' +
            'YTUYQyVcwARKpY6usAhsuiiGgJABRpijSV8ZdJThQRjavFplgFY2A0FkdzkqX0HUaimf7GHboq2koAJrKMaAKMls0xTVs' +
            'VgBUZpmUWGM2ZaxkW1z/EJFrGwGBsVc6JxkFnYZVsBwYTm7LcVzJa3Q5dFc3oLvkeZZr2Wpz8qDBTMpO7ZKvNhmgxUOii' +
            'oQkw1mG7wRRtngIlrJpmcJfJdrtVsv1mXm2Sdkk0cz963i+3RMsvXcJibJfOEtOyPb941Q8DI7H5ekm0Up78sfGRuWusk' +
            'iVXLxQxEJt7a6LtrauXIxnI9bBKVsJZltGRsdJ7w5uWcTirMDoyx1NpWinh6sgK6DmhVCRLbl/02WssXyw8igZ2mmVsmX' +
            'yBEY3fvlBcQo+Jte8T7fIFksLMMtnKx4iWXvwbZpbJNQtvCCs/vrZ+Bz11UC6yeRZczur/MJPecDisacnVdVt9H2Zsr1x' +
            'Eu3FpsOhZxl6GOl/J3i24nuj3BIhHikW4pME7hVrOUe/LqmdWSriV7FHmKlct88SX3l7IoLMY1y6i+SnAh7JezgDGRzP1' +
            'hkSi5Q3extquy5mp6pFFAPchY3EQzKrU0JYS7kPGokBFstG7/N7bpSW0nFhrFtFGvgXwPZmAVkt92w50M0Uj1/dkrNXDy' +
            '1YFVeT6dMzqaJ1yb1cuoilXI5lgLd172c/2CY2O+wayVp47HtbPz+giGrmaypoPjeVBGD6f0IISvteuTRpLRqFOySpXDt' +
            'BQ1pzG9AdMhae0WdL0vS/NaSxRrHPZ0Gr301m+/oF17LC3p9Pp0zntTULDds0+D8tdjsZjdJ3TZnkXH2lDto/nxrJ9ONY' +
            'daaH6qu8lOhhaHAzGthfHkl0xSb4eTh9V2kW0J5WdgK6Lob0+/P49wX79CoeLuVucdohjb/g8GDxWLPwiGdHeBbSYPKO5' +
            'Dz9+Y1qGPVA/qUHVkXayz4BDyxUnsNEP7DaN+mdoYQ4dJK26qXJp2qSm3ZLVNLuEjpLiCPufRikW2U5p47DTS4DZjlZJt' +
            'Iv7JNvZOv0cuozG5kz+yk5ok2uH2uM0sqCPmFwS7DOHWviWQH8lP/+lkex8aoPgLYWe48v32fjioUau6WjJCzBUkby/2+' +
            'EAYROVYv16eLJnb1FT0x+aEBy4CLeWVAAAAABJRU5ErkJggg==';

        this.loadingTxtBase64Img = '' +
            'MFBMVEUAAAD///////////////////////////////////////////////////////////87TQQwAAAAD3RSTlMAu90iR' +
            'BF3M2ZV7pmqzIjYy2KkAAABmElEQVQoz3XRv0tCURQH8K/5O63nHSII4smDpoYnFK06CI2+pqDFNzRF4DNqF1qsRf8DJX' +
            'DWKWhSgqYGW5otiNae2k9/nZ7eZ3nNDo/Hufd+DudwL4A4JmIDcEZ4OnlEk4YAydyyF076a5zxOMW3JbO+9L/xkBUtyQw' +
            '2ZxmJiEx4s1nKns2bkGOCKdDwmBteMGdil1fxMMfGhPU9MkaMyX3GmDFpAIJU5OZaURVFUcn6GdaS9xolLSTD3ACJO8Ax' +
            'mkIw3j6iP6aqA0GKLGRE42oiGuLmSKELRbklI5oXja+LhG3SK8Nxnyl/oIlm8R2JGjfYKzlq8JO+DtEEv5Cr2OZFl8Lw0' +
            'tWHeD+YayP1wI2fmNxkJ7RamzLRolXOjWu0F1PJEHtZjVDNcAMDVi/UuwA8um38eaCRRyNmG0BaO46lSngS3tTb0VDWuH' +
            'FvHqpEr+U2ZME4Bpq/A2n8vo3e5XmnC0UwhbcCDWyT3o9Y88jLdNoTTE5P0g1+5wnvNLUUfQrGxTuGEKhwE7iHTx3lcDP' +
            'MCqcGDVPxDd/zAIW9A4ncAAAAAElFTkSuQmCC';

        let w = gContext.app.renderer.width;
        let h = gContext.app.renderer.height;
        this.background0 = new PIXI.Graphics();
        this.background0.beginFill(0x0, 0.1);
        this.background0.drawRect(-w / 2, -h / 2, w, h);
        this.background0.endFill();
        this.background0.interactive = true;
        this.addChild(this.background0);

        this.background1 = new PIXI.Graphics();
        this.background1.beginFill(0x0, 0.3);
        this.background1.drawRoundedRect(-115, -115, 230, 230, 20);
        this.background1.endFill();
        this.addChild(this.background1);

        this.loadingPointText0 = new PIXI.Graphics();
        this.loadingPointText0.beginFill(0xffffff, 1);
        this.loadingPointText0.drawCircle(0, 0, 2);
        this.loadingPointText0.endFill();
        this.loadingPointText0.x = 30;
        this.loadingPointText0.y = 8;
        this.addChild(this.loadingPointText0);

        this.loadingPointText1 = new PIXI.Graphics();
        this.loadingPointText1.beginFill(0xffffff, 1);
        this.loadingPointText1.drawCircle(0, 0, 2);
        this.loadingPointText1.endFill();
        this.loadingPointText1.visible = false;
        this.loadingPointText1.x = 37;
        this.loadingPointText1.y = 8;
        this.addChild(this.loadingPointText1);

        this.loadingPointText2 = new PIXI.Graphics();
        this.loadingPointText2.beginFill(0xffffff, 1);
        this.loadingPointText2.drawCircle(0, 0, 2);
        this.loadingPointText2.endFill();
        this.loadingPointText2.visible = false;
        this.loadingPointText2.x = 44;
        this.loadingPointText2.y = 8;
        this.addChild(this.loadingPointText2);

        let loadingProgressImgTexture = PIXI.utils.TextureCache['loading_progress_img'];
        if (!loadingProgressImgTexture) {
            let image = new Image();
            image.src = this.progressBase64Img;
            loadingProgressImgTexture = new PIXI.Texture(new PIXI.BaseTexture(image));
            PIXI.Texture.addToCache(loadingProgressImgTexture, 'loading_progress_img');
        }

        this.progressBar = new PIXI.Sprite(loadingProgressImgTexture);
        this.progressBar.anchor.set(0.5, 0.5);
        this.addChild(this.progressBar);

        let loadingTextTexture = PIXI.utils.TextureCache['loading_text'];
        if (!loadingTextTexture) {
            let image = new Image();
            image.src = this.loadingTxtBase64Img;
            loadingTextTexture = new PIXI.Texture(new PIXI.BaseTexture(image));
            PIXI.Texture.addToCache(loadingTextTexture, 'loading_text');
        }
        this.loadingText = new PIXI.Sprite(loadingTextTexture);
        this.loadingText.anchor.set(0.5, 0.5);
        this.loadingText.x = -10;
        this.addChild(this.loadingText);

        this.x = gContext.app.renderer.width / 2;
        this.y = gContext.app.renderer.height / 2;
    }
}